home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
embedded
/
mcu11
/
gloade9a.arc
/
GLOADE9.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-08-13
|
42KB
|
1,340 lines
'*****************************************************************************
'**************** ****************
'**************** E9 Gang Programmer ****************
'**************** ****************
'*****************************************************************************
'* *
'* Program Name: GLOADE9.BAS *
'* Revision: 0.03 *
'* Date: 3/17/91 *
'* Written By: Robert Chretien *
'* Motorola MCU Applications *
'* Compiled Under: Microsoft QuickBASIC Version 4.00 *
'* *
'* Program Description: *
'* *
'* *
'* *
'* *
'* *
'*****************************************************************************
'* *
'* Revision Descriptions: *
'* 1. Rev 0.03: Original program. Modified from GLOADD3.BAS Rev 0.03. *
'* Added routines to program, verify, and compare EEProm. *
'* *
'* *
'* *
'*****************************************************************************
'*****************************************************************************
'
'
'
Initialization:
DIM RAMLoadByte(300)
DIM GoodBoard(10)
Debug = 0
HexConvert$ = "0123456789ABCDEF"
OPEN "CONFIG.PE9" FOR INPUT AS #1
INPUT #1, ComPort, ResponseTime
CLOSE
ON ERROR GOTO ErrorTrap
PickMainOption:
CLS
LOCATE 4, 16
PRINT "Motorola MC68HC711E9 GangProgramming Software"
LOCATE 5, 16
PRINT " Version 0.03"
LOCATE 9, 10
PRINT "1) EPROM Blank Check"
LOCATE 10, 10
PRINT "2) Program and Verify EPROM and/or EEPROM"
LOCATE 11, 10
PRINT "3) Program and Verify multiple sets of boards with same program"
LOCATE 12, 10
PRINT "4) Verify EPROM and/or EEPROM Contents"
LOCATE 13, 10
PRINT "5) Test and Debug"
LOCATE 15, 10
PRINT "S) For System Configuration"
LOCATE 16, 10
PRINT "X) To EXIT program"
LOCATE 18, 10
INPUT "Enter number of desired selection"; OptionChoice$
IF OptionChoice$ = "X" OR OptionChoice$ = "x" THEN GOSUB ThatsAll
IF OptionChoice$ = "S" OR OptionChoice$ = "s" THEN
GOSUB Config
GOTO PickMainOption
END IF
OptionChoice = VAL(OptionChoice$)
NoBoards = 8
PartType$ = "E9"
RAMAddressLow$ = "0000": RAMAddressHigh$ = "01FF"
EEPromAddressLow$ = "B600": EEPromAddress$ = "B7FF"
EPromAddressLow$ = "D000": EPromAddressHigh$ = "FFFF"
MSBBootAddress$ = "BF": LSBBootAddress$ = "4D"
IF OptionChoice = 0 THEN GOSUB ThatsAll
IF OptionChoice = 1 THEN GOSUB Check4Blank
IF OptionChoice = 2 THEN GOSUB ProgProm
Choice3:
IF OptionChoice = 3 THEN
IF RepeatFileName$ = "" THEN
RepeatFileName1:
CLS
LOCATE 10, 1
INPUT "Enter file name to program into HC11"; RepeatFileName$
IF RepeatFileName$ = "" THEN GOTO RepeatFileName1
END IF
GOSUB ProgProm
END IF
IF OptionChoice = 3 THEN
PRINT "Change parts and hit ENTER when ready to program again"
INPUT "Or enter X to return to main menu"; CR$
IF CR$ = "X" OR CR$ = "x" THEN
RepeatFileName$ = ""
GOTO PickMainOption
END IF
GOTO Choice3
END IF
IF OptionChoice = 4 THEN GOSUB VerProm
IF OptionChoice = 5 THEN
DeBugChoice:
CLS
LOCATE 4, 18
PRINT "MC68HC711E9 Board Test and Debug"
LOCATE 8, 10
PRINT "1) Test PC to E9 board connection."
LOCATE 9, 10
PRINT "2) Load Test Program into RAM and Execute"
LOCATE 10, 10
PRINT "3) Program EPROM with Test Program and Execute"
LOCATE 11, 10
PRINT "4) Program EEPROM with Test Program and Execute"
LOCATE 12, 10
PRINT "5) Compare file to HC11 memory"
LOCATE 15, 10
PRINT "X) Return to main menu"
LOCATE 17, 10
INPUT "Enter number of desired selection"; DeBugChoice$
IF DeBugChoice$ = "X" OR DeBugChoice$ = "x" THEN GOTO PickMainOption
IF DeBugChoice$ = "1" THEN GOSUB CheckConnection
IF DeBugChoice$ = "2" THEN GOSUB TestWithRAM
IF DeBugChoice$ = "3" THEN GOSUB TestProgProm
IF DeBugChoice$ = "4" THEN GOSUB TestProgEEProm
IF DeBugChoice$ = "5" THEN GOSUB VerProm
GOTO DeBugChoice
END IF
GOTO PickMainOption
WhatNext:
' download finished. what now?
ThatsAll:
CLOSE
END
'*****************************************************************************
'*****************************************************************************
'* *
'* First level subroutines *
'* *
'*****************************************************************************
'*
'*
'*
Config:
CLS
LOCATE 3, 10
PRINT "Configuration Menu"
LOCATE 6, 5
PRINT "Enter the number corresponding to the serial port in use."
LOCATE 8, 5
PRINT "1) COM1"
LOCATE 9, 5
PRINT "2) COM2"
LOCATE 11, 5
INPUT "HC711E9 board connected to serial port"; ComPort
IF ComPort = 0 THEN GOTO Config
IF ComPort > 2 THEN GOTO Config
LOCATE 14, 5
PRINT "Enter the number of the PC description closest to your machine"
PRINT " NOTE: If in doubt pick a slower machine"
MachineType:
LOCATE 16, 5
PRINT "1) Slow PC/XT (Non-Turbo)"
LOCATE 17, 5
PRINT "2) Fast PC/XT (Turbo)"
LOCATE 18, 5
PRINT "3) Slow PC/AT/XT-286 (6MHz to 10MHz)"
LOCATE 19, 5
PRINT "4) Medium Speed PC/AT/XT-286 (12MHz to 16MHz)"
LOCATE 20, 5
PRINT "5) Fast PC/AT/XT-286 (Faster than 16MHz)"
LOCATE 21, 5
PRINT "6) 386 Machines"
LOCATE 23, 5
INPUT "Machine Type"; Machine
IF Machine = 0 THEN GOTO MachineType
IF Machine = 1 THEN ResponseTime = 100
IF Machine = 2 THEN ResponseTime = 200
IF Machine = 3 THEN ResponseTime = 400
IF Machine = 4 THEN ResponseTime = 500
IF Machine = 5 THEN ResponseTime = 600
IF Machine = 6 THEN ResponseTime = 800
IF Machine > 6 THEN GOTO MachineType
INPUT "Is the above correct"; CR$
IF CR$ <> "Y" AND CR$ <> "y" THEN GOTO Config
INPUT "Save configuration to disk"; CR$
IF CR$ <> "Y" AND CR$ <> "y" THEN GOTO ConfigDone
OPEN "CONFIG.PE9" FOR OUTPUT AS #1
PRINT #1, ComPort, ResponseTime
CLOSE
ConfigDone:
RETURN
'*
'*
'*
Check4Blank:
BootLoad = 1: FirstRecordSent = 0: BlankCheck = 1
CheckSum = 0: Verify = 0: TalkAddress = 8
Filename$ = "GBlankE9.MX"
CLS
LOCATE 1, 1
PRINT "Downloading code into RAM for blank checking."
GOSUB CheckFile
GOSUB ConvertFile4RAM
GOSUB RAMSendFile
GOSUB PollAfterBootLoad
CLS
PRINT "Board Status:"
PRINT
FOR I = 1 TO 8
PRINT "Board "; I - 1
IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
IF GoodBoard(I) = 1 THEN PRINT "Part verified as blank."
IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
IF GoodBoard(I) = 3 THEN PRINT "Part NOT blank."
NEXT I
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
PRINT #1, CHR$(value);
CLOSE #1
PRINT : PRINT
IF TalkAddress = 8 THEN
PRINT "No boards are responding."
PRINT "Reset the HC11."
END IF
INPUT "Hit ENTER to continue"; CR$
RETURN
ProgProm:
FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
CheckSum = 5: Verify = 0
Filename$ = "GPROGE9.MX"
CLS
LOCATE 1, 1
PRINT "Downloading code into RAM for PROM programming."
GOSUB CheckFile
GOSUB ConvertFile4RAM
GOSUB RAMSendFile
GOSUB PollAfterBootLoad
CLS
PRINT "Board Status:"
PRINT
FOR I = 1 TO 8
PRINT "Board "; I - 1
IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
NEXT I
BootLoad = 0
LOCATE 21, 1
IF TalkAddress = 8 THEN
PRINT "No boards are responding."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to Continue."; CR$
GOTO PickMainOption
ELSE
PRINT "RAM ready to program PROM."
IF OptionChoice = 3 THEN
Filename$ = RepeatFileName$
GOTO Option3
END IF
Filename1:
LOCATE 23, 1
PRINT "Or reset the HC11 then enter X to return to main menu."
LOCATE 22, 1
INPUT "Enter file to be downloaded into PROM"; Filename$
IF Filename$ = "" THEN GOTO Filename1
IF Filename$ = "X" OR Filename$ = "x" THEN GOTO PickMainOption
END IF
Option3:
GOSUB CheckFile
GOSUB SendFile
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
PRINT #1, CHR$(value);
CLOSE #1
CLS
PRINT "PROM has been programmed."
CLOSE #2
TempFileName$ = Filename$
GOSUB VerProm
RETURN
VerProm:
FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
CheckSum = 5: Verify = 1
Filename$ = "GVERE9.MX"
CLS
LOCATE 1, 1
PRINT "Downloading code into RAM for PROM verification."
GOSUB CheckFile
GOSUB ConvertFile4RAM
GOSUB RAMSendFile
GOSUB PollAfterBootLoad
CLS
PRINT "Board Status:"
PRINT
FOR I = 1 TO 8
PRINT "Board "; I - 1
IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
NEXT I
BootLoad = 0
IF OptionChoice = 2 OR OptionChoice = 3 OR DeBugChoice$ = "3" OR DeBugChoice$ = "4" THEN
Filename$ = TempFileName$
ELSE
IF TalkAddress = 8 THEN
LOCATE 22, 1
PRINT "No boards are responding."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
GOTO PickMainOption
END IF
Filename2:
LOCATE 23, 1
PRINT "Or reset the HC11 then enter X to return to main menu."
LOCATE 22, 1
INPUT "Enter file to be verified against PROM"; Filename$
IF Filename$ = "" THEN GOTO Filename2
IF Filename$ = "X" OR Filename$ = "x" THEN GOTO PickMainOption
IF DeBugChoice$ = "5" THEN
GOSUB CheckFile
GOSUB CompareFile
GOTO Verf
END IF
END IF
GOSUB CheckFile
GOSUB SendFile
Verf:
VerifyFirstOnly = 0: SentValue = 0: CheckSum = 0
CLS
LOCATE 1, 1
PRINT "Polling boards for verification."
CLOSE
GOSUB PollAfterBootLoad
CLS
PRINT "Board Status:"
PRINT
FOR I = 1 TO 8
PRINT "Board "; I - 1
IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
IF GoodBoard(I) = 1 THEN PRINT "Part verified correctly."
IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
IF GoodBoard(I) = 3 THEN PRINT "Part does NOT verify."
NEXT I
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
PRINT #1, CHR$(value);
CLOSE #1
PRINT : PRINT
INPUT "Hit ENTER to continue"; CR$
RETURN
CheckConnection:
BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
CheckSum = 0: Verify = 0
Filename$ = "GConE9.MX"
CLS
LOCATE 1, 1
PRINT "Downloading code into RAM to check connection."
GOSUB CheckFile
GOSUB ConvertFile4RAM
GOSUB RAMSendFile
GOSUB PollAfterBootLoad
CLS
PRINT "Board Status:"
PRINT
FOR I = 1 TO 8
PRINT "Board "; I - 1
IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
IF GoodBoard(I) = 1 THEN PRINT "Board connection verified."
IF GoodBoard(I) = 2 THEN PRINT "Board not responding correctly."
IF GoodBoard(I) = 3 THEN PRINT "Board not responding correctly."
NEXT I
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
PRINT #1, CHR$(value);
CLOSE #1
PRINT : PRINT
INPUT "Hit ENTER to continue"; CR$
RETURN
TestWithRAM:
BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
CheckSum = 0: Verify = 0
Filename$ = "LEDE9.MX"
CLS
LOCATE 1, 1
PRINT "Downloading code into RAM for Board Test."
GOSUB CheckFile
GOSUB ConvertFile4RAM
GOSUB RAMSendFile
CLS
PRINT "Red LED Should blink 16 times."
INPUT "Hit RETURN when complete."; CR$
RETURN
TestProgProm:
FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
CheckSum = 5: Verify = 0
Filename$ = "GPROGE9.MX"
CLS
LOCATE 1, 1
PRINT "Downloading code into RAM for PROM programming."
GOSUB CheckFile
GOSUB ConvertFile4RAM
GOSUB RAMSendFile
GOSUB PollAfterBootLoad
CLS
PRINT "Board Status:"
PRINT
FOR I = 1 TO 8
PRINT "Board "; I - 1
IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
NEXT I
BootLoad = 0
LOCATE 21, 1
PRINT "RAM ready to program PROM."
Filename$ = "E9Blink.MX"
GOSUB CheckFile
GOSUB SendFile
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
PRINT #1, CHR$(value);
CLOSE #1
CLS
CLOSE #2
TempFileName$ = Filename$
GOSUB VerProm
BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
CheckSum = 0: Verify = 0
Filename$ = "GJMPE9.MX"
CLS
LOCATE 1, 1
PRINT "Downloading code into RAM to jump to EPROM."
GOSUB CheckFile
GOSUB ConvertFile4RAM
GOSUB RAMSendFile
GOSUB PollAfterBootLoad
CLS
PRINT "Board Status:"
PRINT
FOR I = 1 TO 8
PRINT "Board "; I - 1
IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
IF GoodBoard(I) = 1 THEN PRINT "Board connection verified."
IF GoodBoard(I) = 2 THEN PRINT "Board not responding correctly."
IF GoodBoard(I) = 3 THEN PRINT "Board not responding correctly."
NEXT I
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
PRINT #1, CHR$(value);
CLOSE #1
PRINT
PRINT "PROM has been programmed."
PRINT "The LED's should blink 16 times."
INPUT "Hit RETURN when finished"; CR$
RETURN
TestProgEEProm:
FirstRecordSent = 0: BootLoad = 1: BlankCheck = 0
CheckSum = 5: Verify = 0
Filename$ = "GPROGE9.MX"
CLS
LOCATE 1, 1
PRINT "Downloading code into RAM for PROM programming."
GOSUB CheckFile
GOSUB ConvertFile4RAM
GOSUB RAMSendFile
GOSUB PollAfterBootLoad
CLS
PRINT "Board Status:"
PRINT
FOR I = 1 TO 8
PRINT "Board "; I - 1
IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
IF GoodBoard(I) = 1 THEN PRINT "Board responded correctly."
IF GoodBoard(I) = 2 THEN PRINT "Board not responding to address correctly."
IF GoodBoard(I) = 3 THEN PRINT "Board not responding to checksum correctly."
NEXT I
BootLoad = 0
LOCATE 21, 1
PRINT "RAM ready to program PROM."
Filename$ = "E9E2Blnk.MX"
GOSUB CheckFile
GOSUB SendFile
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
PRINT #1, CHR$(value);
CLOSE #1
CLS
CLOSE #2
TempFileName$ = Filename$
GOSUB VerProm
BootLoad = 1: FirstRecordSent = 0: BlankCheck = 0
CheckSum = 0: Verify = 0
Filename$ = "GJMPEE9.MX"
CLS
LOCATE 1, 1
PRINT "Downloading code into RAM to jump to EPROM."
GOSUB CheckFile
GOSUB ConvertFile4RAM
GOSUB RAMSendFile
GOSUB PollAfterBootLoad
CLS
PRINT "Board Status:"
PRINT
FOR I = 1 TO 8
PRINT "Board "; I - 1
IF GoodBoard(I) = 0 THEN PRINT "Board not checked."
IF GoodBoard(I) = 1 THEN PRINT "Board connection verified."
IF GoodBoard(I) = 2 THEN PRINT "Board not responding correctly."
IF GoodBoard(I) = 3 THEN PRINT "Board not responding correctly."
NEXT I
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
PRINT #1, CHR$(value);
CLOSE #1
PRINT
PRINT "PROM has been programmed."
PRINT "The LED's should blink 16 times."
INPUT "Hit RETURN when finished"; CR$
RETURN
'*****************************************************************************
'*****************************************************************************
'* *
'* Level two subroutines *
'* *
'*****************************************************************************
'*****************************************************************************
'*****************************************************************************
'* *
'* This routine checks for non S-records in files *
'* *
'*****************************************************************************
CheckFile:
CLS
LOCATE 10, 10
PRINT "Checking the S19 file for validity and address ranges."
RecordCount = 0
RAMAddressLow = 0: RAMAddressHigh = 511
EEPromAddressLow = 46592: EEPromAddressHigh = 47103
EPromAddressLow = 53248: EPromAddressHigh = 65535
OPEN Filename$ FOR INPUT AS #2
NoS1Records:
INPUT #2, record$
IF LEFT$(record$, 2) = "S0" THEN GOTO NoS1Records
IF LEFT$(record$, 2) = "S1" THEN
RecordCount = RecordCount + 1
Nibble$ = MID$(record$, 3, 1)
Nibble = INSTR(HexConvert$, Nibble$) - 1
IF Nibble = -1 THEN
CLS
PRINT "Error converting number1 to hex."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
CheckLength = Nibble * 16
Nibble$ = MID$(record$, 4, 1)
Nibble = INSTR(HexConvert$, Nibble$) - 1
IF Nibble = -1 THEN
CLS
PRINT "Error converting number2 to hex."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
CheckLength = (CheckLength + Nibble) - 4
CheckAddress$ = MID$(record$, 5, 4)
Nibble$ = LEFT$(CheckAddress$, 1)
Nibble = INSTR(HexConvert$, Nibble$) - 1
IF Nibble = -1 THEN
CLS
PRINT "Error converting number1 to hex."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
CheckAddress = Nibble * 4096
Nibble$ = MID$(CheckAddress$, 2, 1)
Nibble = INSTR(HexConvert$, Nibble$) - 1
IF Nibble = -1 THEN
CLS
PRINT "Error converting number2 to hex."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
CheckAddress = CheckAddress + (Nibble * 256)
Nibble$ = MID$(CheckAddress$, 3, 1)
Nibble = INSTR(HexConvert$, Nibble$) - 1
IF Nibble = -1 THEN
CLS
PRINT "Error converting number3 to hex."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
CheckAddress = CheckAddress + (Nibble * 16)
Nibble$ = RIGHT$(CheckAddress$, 1)
Nibble = INSTR(HexConvert$, Nibble$) - 1
IF Nibble = -1 THEN
CLS
PRINT "Error converting number4 to hex."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
CheckAddress = CheckAddress + Nibble
IF BootLoad = 1 THEN
IF CheckAddress + CheckLength > RAMAddressHigh THEN GOTO AddressError
GOTO NoS1Records
END IF
IF CheckAddress < EEPromAddressLow THEN GOTO AddressError
IF CheckAddress + CheckLength > EEPromAddressHigh AND CheckAddress < EPromAddressLow THEN
GOTO AddressError
END IF
IF CheckAddress + CheckLength > EPromAddressHigh THEN GOTO AddressError
GOTO NoS1Records
END IF
IF LEFT$(record$, 2) = "S9" THEN
IF RecordCount = 0 THEN
CLOSE
CLS
LOCATE 12, 1
PRINT "There are no S1 records in this file."
INPUT "Hit enter to continue"; CR$
RETURN PickMainOption
ELSE
CLOSE #2
RETURN
END IF
END IF
CLOSE
CLS
LOCATE 12, 1
PRINT "This file contains one or more none S19 records."
INPUT "Hit enter to continue"; CR$
RETURN PickMainOption
AddressError:
' CLS
CLOSE
PRINT "S-record file contains address not available in this part."
PRINT "File name: "; Filename$
PRINT "Record Number "; RecordCount
PRINT "Record = "; record$
PRINT "Record start address: $"; HEX$(CheckAddress)
PRINT "Record end address: $"; HEX$(CheckAddress + CheckLength)
PRINT
PRINT "Reset the HC11."
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
'*****************************************************************************
'* *
'* Convert from S-records for fast download to RAM using Bootloader *
'* *
'* *
'*****************************************************************************
ConvertFile4RAM:
RAMLoadByte$ = CHR$(255)
RecordCount = 0
OPEN Filename$ FOR INPUT AS #2
RAMNoS1Records:
INPUT #2, record$
IF LEFT$(record$, 2) = "S0" THEN GOTO RAMNoS1Records
IF LEFT$(record$, 2) = "S1" THEN
record$ = RIGHT$(record$, LEN(record$) - 6)
RecordCount = RecordCount + 1
NextConvertByte:
record$ = RIGHT$(record$, LEN(record$) - 2)
IF LEN(record$) > 2 THEN
ConvertByte$ = LEFT$(record$, 2)
Nibble$ = LEFT$(ConvertByte$, 1)
Nibble = INSTR(HexConvert$, Nibble$) - 1
IF Nibble = -1 THEN
CLS
PRINT "Error converting number1 to hex"
INPUT CR$
RETURN
END IF
MSBNibble = Nibble * 16
Nibble$ = RIGHT$(ConvertByte$, 1)
Nibble = INSTR(HexConvert$, Nibble$) - 1
IF Nibble = -1 THEN
CLS
PRINT "Error converting number1 to hex"
INPUT CR$
RETURN
END IF
value = MSBNibble + Nibble
RAMLoadByte$ = RAMLoadByte$ + CHR$(value)
GOTO NextConvertByte
END IF
GOTO RAMNoS1Records
END IF
IF LEFT$(record$, 2) = "S9" THEN
IF RecordCount = 0 THEN
CLOSE
CLS
LOCATE 12, 1
PRINT "There are no S1 records in this file."
INPUT "Hit enter to continue"; CR$
RETURN PickMainOption
ELSE
CLOSE
CLS
RETURN
END IF
END IF
CLOSE
CLS
LOCATE 12, 1
PRINT "This file contains one or more none S19 records."
INPUT "Hit enter to continue"; CR$
RETURN PickMainOption
'*****************************************************************************
'* *
'* This routine programs RAM using bootloader *
'* *
'*****************************************************************************
RAMSendFile:
LOCATE 4, 1
PRINT "Transfering control program to HC11 RAM."
I = 0
IF ComPort = 1 THEN OPEN "COM1:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
PRINT #1, RAMLoadByte$;
CLOSE
RETURN
'*****************************************************************************
'* *
'* This routine sends file to HC11 *
'* *
'*****************************************************************************
SendFile:
OPEN Filename$ FOR INPUT AS #2
IF BootLoad = 1 THEN
IF ComPort = 1 THEN OPEN "COM1:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
value = 255
PRINT #1, CHR$(value);
END IF
IF BootLoad = 0 THEN
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
END IF
BytesSent = 0
RecordsSent = 0
CLS
LOCATE 10, 10
PRINT "Number of records to be sent: "; RecordCount
LOCATE 11, 10
PRINT "Records sent: "
SendFileLength:
IF BootLoad = 0 THEN
TransErrorCode = 0
value = TalkAddress
GOSUB TRANSxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of talk address failed."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
END IF
GetRecord:
INPUT #2, record$
RecordType$ = LEFT$(record$, 2)
IF RecordType$ = "S0" THEN
GOTO GetRecord
END IF
IF RecordType$ = "S1" THEN
RecordsSent = RecordsSent + 1
LOCATE 11, 24
PRINT RecordsSent
RecordLength$ = MID$(record$, 3, 2)
RecordAddress$ = MID$(record$, 5, 4)
record$ = RIGHT$(record$, LEN(record$) - 8)
ParseAndSend:
IF BootLoad = 1 THEN
TransErrorCode = 0
IF LEN(record$) > 2 THEN
TransHexValue$ = LEFT$(record$, 2)
record$ = RIGHT$(record$, LEN(record$) - 2)
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification failed."
PRINT "Successfully sent "; RecordsSent; " S1 records."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
ELSE
GOTO ParseAndSend
END IF
ELSE
GOTO GetRecord
END IF
ELSE
SendAddress:
TransErrorCode = 0
TransHexValue$ = LEFT$(RecordAddress$, 2)
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of MSB of address failed."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
TransHexValue$ = RIGHT$(RecordAddress$, 2)
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of LSB of address failed."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
SendRecordLength:
TransHexValue$ = RecordLength$
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of record length failed."
PRINT "Reset the HC11."
CLOSE
PRINT "Hit RETURN to continue,"; CR$
RETURN PickMainOption
END IF
SendData:
IF LEN(record$) > 2 THEN
TransHexValue$ = LEFT$(record$, 2)
record$ = RIGHT$(record$, LEN(record$) - 2)
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification failed."
' PRINT "Successfully sent "; RecordsSent; " S1 records."
' INPUT "Reset the HC11 then enter RETURN to go to main menu.";CR$
' GOTO PickMainOption
GOTO SendData
ELSE
GOTO SendData
END IF
ELSE
FirstRecordSent = 1
GOTO GetRecord
END IF
END IF
END IF
IF RecordType$ = "S9" THEN
TransErrorCode = 0
TransHexValue$ = "00"
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of end of file1 failed."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
TransErrorCode = 0
TransHexValue$ = "00"
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of end of file2 failed."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
TransErrorCode = 0
TransHexValue$ = "00"
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of end of file3 failed."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
CLOSE #1
CLOSE #2
RETURN
ELSE
PRINT "A Non S19 record has been encountered. Abort Download."
RETURN PickMainOption
END IF
'*****************************************************************************
'* *
'* This routine compares a file to HC11 *
'* *
'*****************************************************************************
CompareFile:
CLS
LOCATE 1, 30
PRINT "File Comparison"
LOCATE 3, 1
INPUT "Which board to compare"; TalkAddress
LOCATE 4, 1
PRINT "File to compare with: "; Filename$
OPEN Filename$ FOR INPUT AS #2
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
BytesSent = 0
RecordsSent = 0
LOCATE 5, 1
PRINT "Number of records to be sent: "; RecordCount
LOCATE 6, 1
PRINT "Records sent: "
SendCFileLength:
TransErrorCode = 0
value = TalkAddress
GOSUB TRANSxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of talk address failed."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
GetCRecord:
INPUT #2, record$
RecordType$ = LEFT$(record$, 2)
IF RecordType$ = "S0" THEN
GOTO GetCRecord
END IF
IF RecordType$ = "S1" THEN
LOCATE 7, 1
PRINT "Transfering following S1 record."
LOCATE 8, 1
PRINT " "
LOCATE 8, 1
PRINT MID$(record$, 5, LEN(record$) - 6)
RecordsSent = RecordsSent + 1
LOCATE 6, 15
PRINT RecordsSent
RecordLength$ = MID$(record$, 3, 2)
RecordAddress$ = MID$(record$, 5, 4)
record$ = RIGHT$(record$, LEN(record$) - 8)
ParseCAndSend:
SendCAddress:
TransErrorCode = 0
TransHexValue$ = LEFT$(RecordAddress$, 2)
MSB$ = LEFT$(RecordAddress$, 2)
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of MSB of address failed."
PRINT "Reset the HC11"
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
TransHexValue$ = RIGHT$(RecordAddress$, 2)
LSB$ = RIGHT$(RecordAddress$, 2)
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of LSB of address failed."
PRINT "Reset the HC11"
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
ELSE
PrintRecord$ = MSB$ + LSB$
LOCATE 10, 1
PRINT " "
LOCATE 10, 1
PRINT PrintRecord$
END IF
SendCRecordLength:
TransHexValue$ = RecordLength$
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of record length failed."
PRINT "Reset the HC11"
CLOSE
PRINT "Hit RETURN to continue,"; CR$
RETURN PickMainOption
END IF
SendCData:
IF LEN(record$) > 2 THEN
TransHexValue$ = LEFT$(record$, 2)
record$ = RIGHT$(record$, LEN(record$) - 2)
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
GOSUB Back2Hex
PrintRecord$ = PrintRecord$ + Byte$
LOCATE 10, 1
PRINT " "
LOCATE 10, 1
PRINT PrintRecord$
IF TransErrorCode <> 1 THEN
LOCATE 14, 1
PRINT "Verification failed."
INPUT "Hit RETURN to continue."; CR$
GOTO SendCData
ELSE
GOTO SendCData
END IF
ELSE
FirstRecordSent = 1
GOTO GetCRecord
END IF
END IF
IF RecordType$ = "S9" THEN
TransErrorCode = 0
TransHexValue$ = "00"
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of end of file1 failed."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
TransErrorCode = 0
TransHexValue$ = "00"
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of end of file2 failed."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
TransErrorCode = 0
TransHexValue$ = "00"
GOSUB SENDxVALUE
VerifyFirstOnly = 1
SentValue = value
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
LOCATE 20, 1
PRINT "Verification of end of file3 failed."
PRINT "Reset the HC11."
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
CLOSE #1
CLOSE #2
RETURN
ELSE
LOCATE 20, 1
PRINT "A Non S19 record has been encountered. Abort Download."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
'*****************************************************************************
'* *
'* *
'* Call into this routine with parameter TransHexValue = string of two *
'* characters consisting of the byte in hex to be sent. *
'* Routine also increments BytesSent *
'* *
'*****************************************************************************
SENDxVALUE:
TESTxCOUNT = 1
FirstByteLoop = 0
ConvertValue:
Nibble$ = LEFT$(TransHexValue$, 1)
Nibble = INSTR(HexConvert$, Nibble$) - 1
IF Nibble = -1 THEN
CLS
PRINT "Error converting number1 to hex."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
MSBNibble = Nibble * 16
Nibble$ = RIGHT$(TransHexValue$, 1)
Nibble = INSTR(HexConvert$, Nibble$) - 1
IF Nibble = -1 THEN
CLS
PRINT "Error converting number2 to hex."
PRINT "Reset the HC11."
CLOSE
INPUT "Hit RETURN to continue."; CR$
RETURN PickMainOption
END IF
value = MSBNibble + Nibble
TRANSxVALUE:
PRINT #1, CHR$(value);
TransErrorCode = 1
RETURN
'*****************************************************************************
'* *
'* *
'* Converts Val1 back to Hex *
'* *
'* *
'*****************************************************************************
Back2Hex:
High = INT(VAL1 \ 16)
High$ = HEX$(High)
Low = VAL1 - (High * 16)
Low$ = HEX$(Low)
Byte$ = High$ + Low$
RETURN
'*****************************************************************************
'* *
'* *
'* Compares rec value with variable "Value" *
'* *
'* *
'*****************************************************************************
CheckRecValue:
TESTxCOUNT = 0
TESTxLOOP1:
IF NOT EOF(1) THEN
INP$ = INPUT$(LOC(1), #1)
VAL1 = ASC(INP$)
IF VAL1 = value THEN
TransErrorCode = 1
BytesSent = BytesSent + 1
RETURN
ELSE
LOCATE 15, 1
PRINT "Value Returned Wrong"
PRINT "Value Sent = "; value
PRINT "Value Received from HC11 ="; VAL1
IF Debug = 1 THEN
INPUT "Hit Return to End"; CR$
END IF
LOCATE 13, 1
PRINT " "
PRINT " "
PRINT " "
PRINT " "
PRINT " "
PRINT " "
TransErrorCode = 0
RETURN
END IF
ELSE
TESTxCOUNT = TESTxCOUNT + 1
IF TESTxCOUNT > ResponseTime THEN
PRINT "HC11 NOT RESPONDING TO VALUE"
PRINT " "
PRINT " "
TransErrorCode = 0
RETURN
ELSE
GOTO TESTxLOOP1
END IF
END IF
'*****************************************************************************
'* *
'* *
'* Check that all parts got boot code correctly *
'* *
'* *
'*****************************************************************************
PollAfterBootLoad:
IF ComPort = 1 THEN OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
IF ComPort = 2 THEN OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
BoardAddress = 0
TalkAddress = 8
FOR I = 1 TO 9
GoodBoard(I) = 1
value = BoardAddress
LOCATE 10, 1
PRINT "Checking RAM download."
LOCATE 12, 1
PRINT "Sending board address: "; BoardAddress
GOSUB TRANSxVALUE
IF BoardAddress = 8 THEN GOTO NextBootPoll
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
GoodBoard(I) = 2
GOTO NextBootPoll
END IF
TalkAddress = BoardAddress
LOCATE 14, 1
PRINT "Verifying Checksum"
GOSUB TRANSxVALUE
value = CheckSum
GOSUB CheckRecValue
IF TransErrorCode <> 1 THEN
GoodBoard(I) = 3
GOTO NextBootPoll
END IF
NextBootPoll:
BoardAddress = BoardAddress + 1
NEXT I
CLOSE #1
RETURN
'*
'*
'*
'*****************************************************************************
'*****************************************************************************
'*
'*
ErrorTrap:
CLS
PRINT "File Name does not exist."
PRINT
PRINT "Enter another file name or"
INPUT "Reset HC11 then enter RETURN to return to main menu."; Filename$
IF Filename$ = "" THEN
RESUME PickMainOption
ELSE
RESUME
END IF
'*
'*
'*
END
'
'
'
'
'
'***************************************************************************
'*************** ***************
'*************** END ROUTINE ***************
'*************** ***************
'***************************************************************************